1 package uba.db.jdbc;
2
3 import java.sql.ResultSet;
4 import java.sql.SQLException;
5 import java.sql.SQLWarning;
6 import java.util.HashMap;
7 import java.util.Map;
8
9 /***
10 * @version $Revision: 1.1.1.1 $
11 */
12 public class SocketConnection implements java.sql.Connection {
13 private Map typeMap;
14 private boolean autoCommit;
15 private boolean closed;
16 private boolean readOnly;
17 private int holdability;
18 private SQLWarning warnings;
19
20 public SocketConnection() {
21 autoCommit = true;
22 holdability = ResultSet.CLOSE_CURSORS_AT_COMMIT;
23 closed = false;
24 typeMap = new HashMap();
25 warnings = null;
26 }
27
28 public java.sql.Statement createStatement() throws SQLException {
29 return createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY, getHoldability());
30 }
31
32 public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException {
33 return prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
34 }
35
36 public java.sql.CallableStatement prepareCall(String sql) throws SQLException {
37 return prepareCall(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
38 }
39
40 public String nativeSQL(String sql) throws SQLException {
41 if (closed) {
42 throw new ConnectionClosedException();
43 }
44
45 return new JdbcEscapedSqlSentence(sql).asNativeSQL();
46 }
47
48 public void setAutoCommit(boolean autoCommit) throws SQLException {
49 if (!autoCommit) {
50 throw new TransactionsUnsupportedExeption();
51 }
52
53 this.autoCommit = autoCommit;
54 }
55
56 public boolean getAutoCommit() throws SQLException {
57 return autoCommit;
58 }
59
60 public void commit() throws SQLException {
61 throw new TransactionsUnsupportedExeption();
62 }
63
64 public void rollback() throws SQLException {
65 throw new TransactionsUnsupportedExeption();
66 }
67
68 public void close() throws SQLException {
69 if (!closed) {
70 closed = true;
71 }
72 }
73
74 public boolean isClosed() throws SQLException {
75 return closed;
76 }
77
78 public java.sql.DatabaseMetaData getMetaData() throws SQLException {
79
80 return new UbaDatabaseMetaData();
81 }
82
83 public void setReadOnly(boolean readOnly) throws SQLException {
84 this.readOnly = readOnly;
85 }
86
87 public boolean isReadOnly() throws SQLException {
88 return readOnly;
89 }
90
91 public void setCatalog(String catalog) throws SQLException {
92
93
94 addWarning(new CatalogsUnsupportedWarning());
95 }
96
97 public String getCatalog() throws SQLException {
98 return null;
99 }
100
101 public void setTransactionIsolation(int level) throws SQLException {
102 throw new TransactionsUnsupportedExeption();
103 }
104
105 public int getTransactionIsolation() throws SQLException {
106 addWarning(new TransactionsUnsupportedWarning());
107 return java.sql.Connection.TRANSACTION_NONE;
108 }
109
110 private void addWarning(SQLWarning warning) {
111 if (warnings == null) {
112 warnings = warning;
113 } else {
114 warnings.setNextWarning(warning);
115 }
116 }
117
118 public java.sql.SQLWarning getWarnings() throws SQLException {
119 if (closed) {
120 throw new ConnectionClosedException();
121 }
122 return warnings;
123 }
124
125 public void clearWarnings() throws SQLException {
126 warnings = null;
127 }
128
129 public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
130 return createStatement(resultSetType, resultSetConcurrency, getHoldability());
131 }
132
133 public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
134 throws SQLException {
135 return new PreparedStatement(this, sql, resultSetType, resultSetConcurrency);
136 }
137
138 public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
139 throw new StoredProceduresUnsupportedException();
140 }
141
142 public Map getTypeMap() throws SQLException {
143 return typeMap;
144 }
145
146 public void setTypeMap(Map typeMap) throws SQLException {
147 this.typeMap = typeMap;
148 }
149
150 public void setHoldability(int holdability) throws SQLException {
151 this.holdability = holdability;
152 }
153
154 public int getHoldability() throws SQLException {
155 return holdability;
156 }
157
158 public java.sql.Savepoint setSavepoint() throws SQLException {
159 throw new TransactionsUnsupportedExeption();
160 }
161
162 public java.sql.Savepoint setSavepoint(String name) throws SQLException {
163 throw new TransactionsUnsupportedExeption();
164 }
165
166 public void rollback(java.sql.Savepoint savepoint) throws SQLException {
167 }
168
169 public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException {
170 throw new TransactionsUnsupportedExeption();
171 }
172
173 public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
174 throws SQLException {
175 return new Statement(this, resultSetType, resultSetConcurrency, resultSetHoldability);
176 }
177
178 public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
179 int resultSetHoldability) throws SQLException {
180
181 return null;
182 }
183
184 public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
185 int resultSetHoldability) throws SQLException {
186
187 return null;
188 }
189
190 public java.sql.PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
191
192 return null;
193 }
194
195 public java.sql.PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
196
197 return null;
198 }
199
200 public java.sql.PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
201
202 return null;
203 }
204 }